package com.zhuzhe.blog.base;

import com.zhuzhe.blog.enums.ResponseEnum;

/**
 * @ClassName: ResponseDataUtil
 * @Description: 返回结果工具类
 * @author: u53
 * @date: 2020/10/21 10:55
 */
public class JsonData {
    public static ResponseData success(Object object){
        ResponseData responseData = new ResponseData();
        responseData.setCode(ResponseEnum.SUCCESS.getCode());
        responseData.setMessage(ResponseEnum.SUCCESS.getMsg());
        responseData.setData(object);
        return responseData;
    }
    public static ResponseData success(){
        return success(null);
    }
    public static ResponseData fail(Integer code, String message){
        ResponseData responseData = new ResponseData();
        responseData.setCode(code);
        responseData.setMessage(message);
        return responseData;
    }
    public static ResponseData fail(ResponseEnum ResponseEnum){
        ResponseData responseData = new ResponseData();
        responseData.setCode(ResponseEnum.getCode());
        responseData.setMessage(ResponseEnum.getMsg());
        return responseData;
    }

    public static ResponseData fail(String message) {
        ResponseData responseData = new ResponseData();
        responseData.setCode(ResponseEnum.OPERATE_FAIL.getCode());
        responseData.setMessage(message);
        return responseData;
    }

    public static ResponseData err(String message) {
        ResponseData responseData = new ResponseData();
        responseData.setCode(ResponseEnum.SYSTEM_RUNNING_ERROR.getCode());
        responseData.setMessage(message);
        return responseData;
    }

    public static ResponseData err() {
        ResponseData responseData = new ResponseData();
        responseData.setCode(ResponseEnum.SYSTEM_RUNNING_ERROR.getCode());
        responseData.setMessage(ResponseEnum.SYSTEM_RUNNING_ERROR.getMsg());
        return responseData;
    }
}
